Resources can be shared between multiple resource consumers, and consumers can request to access a type of resource as required. Examples of types of resource include: communications sockets in a network; storage such as memory or disk; and processor time. Examples of types of consumer include: software threads; application processes; and computer systems. In use, consumers who have a need for a type of resource request access to the type of resource, and a resource of the appropriate type is allocated to the consumer in satisfaction of the request. Once allocated, a resource can be accessed by the consumer as required. Future requirements for access to the same type of resource can arise, and the same or a different resource can be allocated accordingly. Sharing resources between consumers is complex because it is necessary to ensure that, on the one hand, consumers have ready access to a resource when required, and on the other hand, that resources are not contended between a large number of requesting consumers. Contention for a resource arises when two or more consumers attempt to access a resource simultaneously. Such simultaneous access needs to be regulated and techniques for managing contention, such as resource locking and synchronisation, are well known in the art and do not form part of this discussion except insofar as they are resource intensive. For this reason, contention between consumers of a resource is preferably avoided. It is therefore desirable to share a resources in such a way that reduces the likelihood of contention.
One way to manage the sharing of a resource between multiple consumers is to provide exclusive access to a resource for a consumer. This involves a consumer requesting to access a resource, and the consumer being granted exclusive access to the resource until the consumer indicates that it is finished accessing the resource. Only once the consumer is finished accessing the resource will it be made available to another consumer. This approach is effective where the use of a resource by a consumer is determinate, that is, the use of the resource is explicitly terminated when the consumer is finished accessing the resource. In some cases, however, the use of a resource is not determinate because a consumer is not able to indicate when it is finished accessing the resource. In these cases, it is not possible to provide exclusivity over a resource for a consumer since use of the resource can be ongoing for a consumer. Consequently the potential for contention arises.
The likelihood of contention can be reduced by providing multiple resources of a required type of resource. In an extreme, one resource can be provided per requesting consumer with no need to share resources. However, this approach is ineffective where the number of available resources is limited and/or the number of consumers is unknown. Where there is a larger number of consumers than the maximum number of resources there will always be a possibility of contention. In such situations it is desirable to allocate resources to consumers in such a way that contention between the consumers is reduced. It would therefore be advantageous to provide for the sharing of a limited number of resources between multiple consumers in a way which reduces the possibility of contention.